<?php

namespace Common;

use Think\Controller;
use Common\Model\UserHospitalModel;

Class CommonHospitalController extends Controller{

	public $userHospital;	

	public function __construct(){
		parent::__construct();

		//检查token & 保存token&用户信息
		$this->checkToken();
	}

	private function checkToken(){
		$token = I('param.token');
		if(empty($token)){
			$this->ajaxReturn(['status'=>401,'error_info'=>'用户未登陆，请登陆']);
		}

		$userHospitalModel = new UserHospitalModel;
		$res = $userHospitalModel->where(['token'=>$token])->find();
		if($res){
			$this->userHospital = $userHospitalModel;
		}else{
			$this->ajaxReturn(['status'=>401,'error_info'=>'用户登陆信息不正确，请重新登陆']);
		}
	}
	
}

